import { get, post } from './request.js'

/**
 * 我的课程
 * @param params 查询参数
 */
export function getCoursePage(params) {
  return get('/v1/trainee/coursePage', params)
}

export function getAllExercise(params) {
  return get(`/v1/trainee/getAllExercise`, params)
}

export function getReport(exerciseId) {
  return get(`/v1/trainee/exercise/getReport/${exerciseId}`, undefined)
}

export function getReportState(exerciseId) {
  return get(`/v1/trainee/exercise/getReportState/${exerciseId}`, undefined)
}

/**
 * 课程主页
 * @param courseId 课程ID
 */
export function getCourse(courseId) {
  return get(`/v1/trainee/getCourse/${courseId}`, undefined)
}

/**
 * 课程主页-课时详情
 * @param courseId 课程ID
 */
export function getLesson(courseId, lessonId) {
  return get(`/v1/trainee/onStudy`, {
    courseId, lessonId
  })
}

/**
 * 保存练习
 * @param courseId 课程ID
 */
export function saveExercise(body) {
  return post('/v1/trainee/exercise/save', {
    ...body
  })
}
